﻿using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RabbitMQ_Consumer
{
    public class RabbitMQHelper
    {
        /// <summary>
        /// 获取RabbitMQ连接
        /// </summary>
        /// <returns></returns>
        public static IConnection GetConnection()
        {
            //实例化链接工厂
            var factory = new ConnectionFactory
            {
                HostName = "127.0.0.1", //ip
                Port = 5672, // 端口
                UserName = "Admin", // 账户
                Password = "Admin", // 密码
                VirtualHost = "/"   // 虚拟主机
            };

            return factory.CreateConnection();
        }
    }
}
